00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00014 #include "stdafx.h"
00015 #include "TraffEdu.h"
00016 #include "TraffEduDoc.h"
00017 #include "RightView.h"
00018 #include "MainFrm.h"
00019 #include "0SGWindows/OSGEventHandler.h"
00020 #include "0SGWindows/OSGWindows.h"
00021 #include "0SGWindows/timeline.h"
00022 #include "fundementals/Wheel.h"
00023 #include "fundementals/TraffEduObject.h"
00024 #include "fundementals/Vehicle.h"
00025 #include "fundementals/TrafficSign.h"
00026 #include "fundementals/TrafficLight.h"
00027 #include "fundementals/CarModels.h"
00028 #include "GUIEventHandler/CommandCamera.h"
00029 #include "GUIEventHandler/CommandText.h"
00030 #include "TextDlg.h"
00031 #include <osgDB/Registry>
00032 #include <osgDB/ReadFile>
00033 #include <osg/Node>
00034 #include <osg/Matrix>
00035 #include <osg/Geode>
00036 #include <osg/ShapeDrawable>
00037 #include <osg/Material>
00038 #include <osg/Texture2D>
00039 #include <osg/MatrixTransform>
00040 #include <osg/PositionAttitudeTransform>
00041 #include <osg/BlendFunc>
00042 #include <osg/ClearNode>
00043 #include <osg/Projection>
00044 #include <osg/Texture2D>
00045 #include <osgUtil/Tesselator>
00046 #include <osgUtil/CullVisitor>
00047 #include <osgUtil/Optimizer>
00048 #include <osgGA/TrackballManipulator>
00049 #include <osgProducer/Viewer>
00050 #include <osgDB/ReadFile>
00051 #include <osgSim/ScalarsToColors>
00052 #include <osgSim/ColorRange>
00053 #include <osgSim/ScalarBar>
00054 #include <Producer/RenderSurface>
00055 #include <sstream>
00056 #include <math.h>
00057
00058 using namespace osgSim;
00059 using osgSim::ScalarBar;
00060
00061
00062 #include <osg/Depth>
00063 #include <osg/CameraNode>
00064 #include <osg/io_utils>
00065 #include <osgText/Text>
00066 #include <osg/Vec3>
00067 #include <osg/Vec4>
00068 #include <osg/Quat>
00069 #include <osg/Matrix>
00070 #include <osg/ShapeDrawable>
00071 #include <osg/Geometry>
00072 #include <osg/Geode>
00073 #include <osg/Transform>
00074 #include <osg/Material>
00075 #include <osg/NodeCallback>
00076 #include <osg/Depth>
00077 #include <osg/CullFace>
00078 #include <osg/TexMat>
00079 #include <osg/TexGen>
00080 #include <osg/TexEnv>
00081 #include <osg/TexEnvCombine>
00082 #include <osg/TextureCubeMap>
00083 #include <osg/VertexProgram>
00084 #include <osgDB/Registry>
00085 #include <osgDB/ReadFile>
00086 #include ".\rightview.h"
00087
00088
00089 #ifdef _DEBUG
00090 #define new DEBUG_NEW
00091 #endif
00092
00093 UINT WM_OSGMFCSTARTRENDERINGRIGHT = ::RegisterWindowMessage(_T("WM_OSGMFCSTARTRENDERINGRIGHT"));
00094
00095
00096 IMPLEMENT_DYNCREATE(RightView, CWnd)
00097
00098 BEGIN_MESSAGE_MAP(RightView, CWnd)
00099 ON_WM_PAINT()
00100 ON_WM_SIZING()
00101 ON_COMMAND(ID_OBJECTRIGHTMENU_CUT, OnObjectrightmenuCut)
00102 ON_COMMAND(ID_OBJECTRIGHTMENU_COPY, OnObjectrightmenuCopy)
00103 ON_COMMAND(ID_OBJECTRIGHTMENU_DELETE, OnObjectrightmenuDelete)
00104 ON_COMMAND(ID_OBJECTRIGHTMENU_TRANSLATE, OnObjectrightmenuRotate)
00105 ON_COMMAND(ID_FREEPLACERIGHTMENU_PASTE, OnFreeplacerightmenuPaste)
00106 ON_COMMAND(ID_VEHICLE_KAMYON, OnVehicleKamyon)
00107
00108 ON_COMMAND(ID_TRAFFICLIGHT_RED, OnTrafficlightRed)
00109 ON_COMMAND(ID_TRAFFICLIGHT_GREEN, OnTrafficlightYellow)
00110 ON_COMMAND(ID_TRAFFICLIGHT_GREEN32858, OnTrafficlightGreen)
00111 ON_COMMAND(ID_ENVIRONMENTALOBJECT_HOUSE, OnEnvironmentalobjectHouse)
00112 ON_COMMAND(ID_FREEPLACERIGHTMENU_INSERTTEXT, OnFreeplacerightmenuInserttext)
00113 ON_COMMAND(ID_CAMERA_YAWLEFT32849, OnCameraYawleft)
00114 ON_COMMAND(ID_CAMERA_YAWRIGHT32850, OnCameraYawright)
00115 ON_COMMAND(ID_CAMERA_PITCHUP32851, OnCameraPitchup)
00116 ON_COMMAND(ID_CAMERA_PITCHDOWN32852, OnCameraPitchdown)
00117 ON_COMMAND(ID_CAMERA_ZOOMIN32853, OnCameraZoomin)
00118 ON_COMMAND(ID_CAMERA_ZOOMOUT32869, OnCameraZoomout)
00119
00120 ON_COMMAND(Dikkat, OnDikkat)
00121 ON_UPDATE_COMMAND_UI(Dikkat, OnUpdateDikkat)
00122 ON_COMMAND(ID_TRAFFICSIGN_YOLVER32931, OnTrafficsignYolver32931)
00123 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_YOLVER32931, OnUpdateTrafficsignYolver32931)
00124 ON_COMMAND(ID_TRAFFICSIGN_ISIKLIISARETCIHAZI32932, OnTrafficsignIsikliisaretcihazi32932)
00125 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_ISIKLIISARETCIHAZI32932, OnUpdateTrafficsignIsikliisaretcihazi32932)
00126 ON_COMMAND(ID_TRAFFICSIGN_SAGATEHLIKELIVIRAJ32933, OnTrafficsignSagatehlikeliviraj32933)
00127 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SAGATEHLIKELIVIRAJ32933, OnUpdateTrafficsignSagatehlikeliviraj32933)
00128 ON_COMMAND(ID_TRAFFICSIGN_SOLATEHLIKELIVIRAJ32934, OnTrafficsignSolatehlikeliviraj32934)
00129 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SOLATEHLIKELIVIRAJ32934, OnUpdateTrafficsignSolatehlikeliviraj32934)
00130 ON_COMMAND(ID_TRAFFICSIGN_SAGASUREKLITEHLIKELIVIRAJ32935, OnTrafficsignSagasureklitehlikeliviraj32935)
00131 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SAGASUREKLITEHLIKELIVIRAJ32935, OnUpdateTrafficsignSagasureklitehlikeliviraj32935)
00132 ON_COMMAND(ID_TRAFFICSIGN_SOLASUREKLITEHLIKELIVIRAJ32936, OnTrafficsignSolasureklitehlikeliviraj32936)
00133 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SOLASUREKLITEHLIKELIVIRAJ32936, OnUpdateTrafficsignSolasureklitehlikeliviraj32936)
00134 ON_COMMAND(ID_TRAFFICSIGN_SAGANAYOL32937, OnTrafficsignSaganayol32937)
00135 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SAGANAYOL32937, OnUpdateTrafficsignSaganayol32937)
00136 ON_COMMAND(ID_TRAFFICSIGN_SOLANAYOL32942, OnTrafficsignSolanayol32942)
00137 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SOLANAYOL32942, OnUpdateTrafficsignSolanayol32942)
00138 ON_COMMAND(ID_TRAFFICSIGN_SAGADONULMEZ32944, OnTrafficsignSagadonulmez32944)
00139 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SAGADONULMEZ32944, OnUpdateTrafficsignSagadonulmez32944)
00140 ON_COMMAND(ID_TRAFFICSIGN_SOLADONULMEZ32945, OnTrafficsignSoladonulmez32945)
00141 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SOLADONULMEZ32945, OnUpdateTrafficsignSoladonulmez32945)
00142 ON_COMMAND(ID_TRAFFICSIGN_UDONUSUYAPILMAZ32946, OnTrafficsignUdonusuyapilmaz32946)
00143 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_UDONUSUYAPILMAZ32946, OnUpdateTrafficsignUdonusuyapilmaz32946)
00144 ON_COMMAND(ID_TRAFFICSIGN_ONDEKITASITIGECMEKYASAKTIR32947, OnTrafficsignOndekitasitigecmekyasaktir32947)
00145 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_ONDEKITASITIGECMEKYASAKTIR32947, OnUpdateTrafficsignOndekitasitigecmekyasaktir32947)
00146 ON_COMMAND(ID_TRAFFICSIGN_SAGAMECBURIYON32948, OnTrafficsignSagamecburiyon32948)
00147 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SAGAMECBURIYON32948, OnUpdateTrafficsignSagamecburiyon32948)
00148 ON_COMMAND(ID_TRAFFICSIGN_SOLAMECBURIYON32949, OnTrafficsignSolamecburiyon32949)
00149 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SOLAMECBURIYON32949, OnUpdateTrafficsignSolamecburiyon32949)
00150 ON_COMMAND(ID_TRAFFICSIGN_ILERIMECBURIYON32950, OnTrafficsignIlerimecburiyon32950)
00151 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_ILERIMECBURIYON32950, OnUpdateTrafficsignIlerimecburiyon32950)
00152 ON_COMMAND(ID_TRAFFICSIGN_ILERIVASAGAMECBURIYON32951, OnTrafficsignIlerivasagamecburiyon32951)
00153 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_ILERIVASAGAMECBURIYON32951, OnUpdateTrafficsignIlerivasagamecburiyon32951)
00154 ON_COMMAND(ID_TRAFFICSIGN_ILERIVESOLAMECBURIYON32952, OnTrafficsignIlerivesolamecburiyon32952)
00155 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_ILERIVESOLAMECBURIYON32952, OnUpdateTrafficsignIlerivesolamecburiyon32952)
00156 ON_COMMAND(ID_VEHICLE_AUTOMOBILE, OnVehicleAutomobile)
00157 ON_UPDATE_COMMAND_UI(ID_VEHICLE_AUTOMOBILE, OnUpdateVehicleAutomobile)
00158 ON_COMMAND(ID_VEHICLE_TRUCK, OnVehicleTruck)
00159 ON_UPDATE_COMMAND_UI(ID_VEHICLE_TRUCK, OnUpdateVehicleTruck)
00160 ON_COMMAND(ID_ENVIRONMENTALOBJECT_HOUSE32909, OnEnvironmentalobjectHouse32909)
00161 ON_UPDATE_COMMAND_UI(ID_ENVIRONMENTALOBJECT_HOUSE32909, OnUpdateEnvironmentalobjectHouse32909)
00162 ON_UPDATE_COMMAND_UI(ID_ENVIRONMENTALOBJECT_HOUSE, OnUpdateEnvironmentalobjectHouse)
00163 ON_UPDATE_COMMAND_UI(ID_CAMERA_YAWLEFT32849, OnUpdateCameraYawleft32849)
00164 ON_COMMAND(ID_FREEPLACERIGHTMENU_INSERTAUDIO, OnFreeplacerightmenuInsertaudio)
00165 ON_UPDATE_COMMAND_UI(ID_FREEPLACERIGHTMENU_INSERTAUDIO, OnUpdateFreeplacerightmenuInsertaudio)
00166 ON_COMMAND(ID_TRAFFICSIGN_SOLATEHLIKELIVIRAJ32957, OnTrafficsignSolatehlikeliviraj32957)
00167 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SOLATEHLIKELIVIRAJ32957, OnUpdateTrafficsignSolatehlikeliviraj32957)
00168 ON_COMMAND(ID_TRAFFICSIGN_SAGASUREKLITEHLIKELIVIRAJ32958, OnTrafficsignSagasureklitehlikeliviraj32958)
00169 ON_UPDATE_COMMAND_UI(ID_TRAFFICSIGN_SAGASUREKLITEHLIKELIVIRAJ32958, OnUpdateTrafficsignSagasureklitehlikeliviraj32958)
00170 ON_COMMAND(ID_TRAFFICSIGN_SOLASUREKLITEHLIKELIVIRAJ32956, OnTrafficsignSolasureklitehlikeliviraj32956)
00171 ON_COMMAND(ID_TRAFFICSIGN_SAGANAYOL32959, OnTrafficsignSaganayol32959)
00172 ON_COMMAND(ID_TRAFFICSIGN_SOLANAYOL32960, OnTrafficsignSolanayol32960)
00173 ON_COMMAND(ID_TRAFFICSIGN_SAGADONULMEZ32961, OnTrafficsignSagadonulmez32961)
00174 ON_COMMAND(ID_TRAFFICSIGN_SOLADONULMEZ32962, OnTrafficsignSoladonulmez32962)
00175 ON_COMMAND(ID_TRAFFICSIGN_UDONUSUYAPILMAZ32963, OnTrafficsignUdonusuyapilmaz32963)
00176 ON_COMMAND(ID_TRAFFICSIGN_ONDEKITASITIGECMEKYASAKTIR32964, OnTrafficsignOndekitasitigecmekyasaktir32964)
00177 ON_COMMAND(ID_TRAFFICSIGN_SAGAMECBURIYON32965, OnTrafficsignSagamecburiyon32965)
00178 ON_COMMAND(ID_TRAFFICSIGN_SOLAMECBURIYON32966, OnTrafficsignSolamecburiyon32966)
00179 ON_COMMAND(ID_TRAFFICSIGN_ILERIMECBURIYON32967, OnTrafficsignIlerimecburiyon32967)
00180 ON_COMMAND(ID_TRAFFICSIGN_ILERIVASAGAMECBURIYON32968, OnTrafficsignIlerivasagamecburiyon32968)
00181 ON_COMMAND(ID_TRAFFICSIGN_ILERIVESOLAMECBURIYON32969, OnTrafficsignIlerivesolamecburiyon32969)
00182 END_MESSAGE_MAP()
00183
00184
00185 osg::Matrixd myCameraMatrix;
00186 osg::Matrixd cameraRotation;
00187 osg::Matrixd cameraTrans;
00188
00189 osg::TextureCubeMap* readCubeMap()
00190 {
00191 osg::TextureCubeMap* cubemap = new osg::TextureCubeMap;
00192 #define CUBEMAP_FILENAME(face) "Data/sky.png"
00193
00194 osg::Image* imagePosX = osgDB::readImageFile(CUBEMAP_FILENAME(posx));
00195 osg::Image* imageNegX = osgDB::readImageFile(CUBEMAP_FILENAME(negx));
00196 osg::Image* imagePosY = osgDB::readImageFile(CUBEMAP_FILENAME(posy));
00197 osg::Image* imageNegY = osgDB::readImageFile(CUBEMAP_FILENAME(negy));
00198 osg::Image* imagePosZ = osgDB::readImageFile(CUBEMAP_FILENAME(posz));
00199 osg::Image* imageNegZ = osgDB::readImageFile(CUBEMAP_FILENAME(negz));
00200
00201 if (imagePosX && imageNegX && imagePosY && imageNegY && imagePosZ && imageNegZ)
00202 {
00203 cubemap->setImage(osg::TextureCubeMap::POSITIVE_X, imagePosX);
00204 cubemap->setImage(osg::TextureCubeMap::NEGATIVE_X, imageNegX);
00205 cubemap->setImage(osg::TextureCubeMap::POSITIVE_Y, imagePosY);
00206 cubemap->setImage(osg::TextureCubeMap::NEGATIVE_Y, imageNegY);
00207 cubemap->setImage(osg::TextureCubeMap::POSITIVE_Z, imagePosZ);
00208 cubemap->setImage(osg::TextureCubeMap::NEGATIVE_Z, imageNegZ);
00209
00210 cubemap->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
00211 cubemap->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
00212 cubemap->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
00213
00214 cubemap->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);
00215 cubemap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
00216 }
00217
00218 return cubemap;
00219 }
00220
00221 class MoveEarthySkyWithEyePointTransform : public osg::Transform
00222 {
00223 public:
00225 virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
00226 {
00227 osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
00228 if (cv)
00229 {
00230 osg::Vec3 eyePointLocal = cv->getEyeLocal();
00231 matrix.preMult(osg::Matrix::translate(eyePointLocal));
00232 }
00233 return true;
00234 }
00235
00237 virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
00238 {
00239 osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
00240 if (cv)
00241 {
00242 osg::Vec3 eyePointLocal = cv->getEyeLocal();
00243 matrix.postMult(osg::Matrix::translate(-eyePointLocal));
00244 }
00245 return true;
00246 }
00247 };
00248
00249 struct TexMatCallback : public osg::NodeCallback
00250 {
00251 public:
00252
00253 TexMatCallback(osg::TexMat& tm) :
00254 _texMat(tm)
00255 {
00256 }
00257
00258 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
00259 {
00260 osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
00261 if (cv)
00262 {
00263 const osg::Matrix& MV = cv->getModelViewMatrix();
00264 const osg::Matrix R = osg::Matrix::rotate( osg::DegreesToRadians(112.0f), 0.0f,0.0f,1.0f)*
00265 osg::Matrix::rotate( osg::DegreesToRadians(90.0f), 1.0f,0.0f,0.0f);
00266
00267 osg::Quat q;
00268 MV.get(q);
00269 const osg::Matrix C = osg::Matrix::rotate( q.inverse() );
00270
00271 _texMat.setMatrix( C*R );
00272 }
00273
00274 traverse(node,nv);
00275 }
00276
00277 osg::TexMat& _texMat;
00278 };
00279
00280 osg::Node* createSkyBox()
00281 {
00282 osg::StateSet* stateset = new osg::StateSet();
00283 osg::Geode* geode = new osg::Geode();
00284
00285 osg::Image* image = osgDB::readImageFile( "Data/sky.png" );
00286
00287 if (image)
00288 {
00289 osg::Texture2D* texture = new osg::Texture2D;
00290 texture->setImage(image);
00291 stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
00292 }
00293 stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
00294 stateset->setMode( GL_CULL_FACE, osg::StateAttribute::OFF );
00295
00296
00297 osg::Depth* depth = new osg::Depth;
00298 depth->setFunction(osg::Depth::ALWAYS);
00299 depth->setRange(1.0,1.0);
00300 stateset->setAttributeAndModes(depth, osg::StateAttribute::ON );
00301
00302 stateset->setRenderBinDetails(-1,"RenderBin");
00303
00304 geode->setStateSet( stateset );
00305 geode->setCullingActive(false);
00306 float radius = 0.8f;
00307 float height = 1.0f;
00308
00309 osg::TessellationHints* hints = new osg::TessellationHints;
00310 hints->setDetailRatio(0.5f);
00311
00312 geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),1000),hints));
00313 osg::ClearNode* clearNode = new osg::ClearNode;
00314
00315
00316 osg::Transform* transform = new MoveEarthySkyWithEyePointTransform;
00317 transform->setCullingActive(false);
00318 transform->addChild(geode);
00319 clearNode->addChild(transform);
00320 return clearNode;
00321 }
00322
00323 OSGWindows* osgwind;
00324
00325
00326 RightView::RightView()
00327 {
00328
00329 osgwind = new OSGWindows();
00330 root = osgwind->getConstantRoot();
00331 m_bInitialised = false;
00332 m_bRenderSurfaceRealized = FALSE;
00333 m_bModelLoaded = FALSE;
00334 m_DatabasePager = NULL;
00335 m_bGotFocus = FALSE;
00336 objectInOperation=NULL;
00337 }
00338
00339 RightView::~RightView()
00340 {
00341 if (osgwind->getViewer().valid() && m_bInitialised)
00342 osgwind->getViewer()->sync();
00343 }
00344
00345 BOOL RightView::PreCreateWindow(CREATESTRUCT& cs)
00346 {
00347 if (!CWnd::PreCreateWindow(cs))
00348 return FALSE;
00349
00350 cs.dwExStyle |= WS_EX_CLIENTEDGE;
00351 cs.style &= ~WS_BORDER;
00352 cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
00353 ::LoadCursor(NULL, IDC_ARROW), reinterpret_cast<HBRUSH>(COLOR_WINDOW+1), NULL);
00354
00355 return TRUE;
00356 }
00357
00358
00359
00360
00361 void RightView::OnPaint()
00362 {
00363
00364 CPaintDC dc(this);
00365
00366 if (!m_bInitialised)
00367 {
00368 osgwind->getViewer()->setUpViewer(osgProducer::Viewer::NO_EVENT_HANDLERS | osgProducer::Viewer::HEAD_LIGHT_SOURCE
00369 osgwind->getViewer()->getCamera(0)->getRenderSurface()->fullScreen(false);
00370 osgwind->getViewer()->getCamera(0)->getRenderSurface()->setWindow((const Producer::Window) GetSafeHwnd());
00371 osgwind->getViewer()->realize(Producer::CameraGroup::SingleThreaded);
00372 SetSceneData();
00373 m_bInitialised = true;
00374 }
00375 RenderFrame();
00376 }
00377
00378 bool RightView::RenderFrame()
00379 {
00380 if (m_bInitialised && osgwind->getViewer().valid() && (osgwind->getViewer()->getSceneData() != NULL))
00381 {
00382 osgwind->getViewer()->sync();
00383 osgwind->getViewer()->update();
00384 osgwind->getViewer()->frame();
00385 return true;
00386 }
00387 else
00388 return false;
00389 }
00390
00391 void RightView::OnSizing(UINT fwSide, LPRECT pRect)
00392 {
00393 RenderFrame();
00394 }
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 void RightView::SetSceneData()
00408 {
00409 cameraRotation.makeRotate(
00410 osg::DegreesToRadians( 0.0), osg::Vec3(0,1,0),
00411 osg::DegreesToRadians( -25.0), osg::Vec3(1,0,0) ,
00412 osg::DegreesToRadians(0.0), osg::Vec3(0,0,1) );
00413 cameraTrans.makeTranslate(0.0,-230.0,70.0 );
00414
00415 myCameraMatrix = cameraRotation * cameraTrans;
00416 osg::Matrixd i = myCameraMatrix.inverse(myCameraMatrix);
00417 osgwind->getViewer()->setViewByMatrix( (
00418 Producer::Matrix(i.ptr() ))
00419 * Producer::Matrix::rotate( -M_PI/2.0, 1, 0, 0 ) );
00420 root->addChild(createSkyBox());
00421
00422 const double GROUND_X = 500.0;
00423 const double GROUND_Y = GROUND_X;
00424 const double GROUND_Z = 0.01;
00425
00426 osg::ref_ptr<osg::Box> groundBox(
00427 new osg::Box (osg::Vec3 (0.0, 0.0,GROUND_Z/2.0),
00428 GROUND_X, GROUND_Y, GROUND_Z/2.0));
00429
00430 osg::ref_ptr<osg::Geode> groundGeode (new osg::Geode);
00431 groundGeode->addDrawable (new osg::ShapeDrawable (groundBox.get()));
00432 CarModels::initialize();
00433 TrafficModel::initialize();
00434 theRoadMap=new RoadMap(osgwind->getConstantRoot().get());
00435 theRoadMap->loadRoadScene();
00436 osgwind->getViewer()->setSceneData(osgwind->getConstantRoot().get());
00437
00438 CMainFrame* pFrame = reinterpret_cast<CMainFrame*>(this->GetParentFrame());
00439
00440 osg::ref_ptr<OSGEventHandler> osgh = new OSGEventHandler (osgwind->getViewer(),pFrame);
00441 osgwind->getViewer()->getEventHandlerList().push_front(osgh.get());
00442 if (root != NULL)
00443 {
00444 osgwind->getViewer()->sync();
00445 osgwind->getViewer()->update();
00446 osgwind->getViewer()->frame();
00447 }
00448
00449
00450 }
00451
00452 void RightView::OnContextMenu(CWnd* pWnd, CPoint point)
00453 {
00454 }
00455
00456 void RightView::OnObjectrightmenuCut()
00457 {
00458 if(objectInOperation!=NULL){
00459 osgwind->addCommandCut(objectInOperation);
00460
00461 }
00462 }
00463
00464
00465
00466 void RightView::OnObjectrightmenuCopy()
00467 {
00468 if(objectInOperation!=NULL){
00469 osgwind->addCommandCopy(objectInOperation);
00470 }
00471 }
00472
00473 void RightView::OnObjectrightmenuDelete()
00474 {
00475 if(objectInOperation!=NULL){
00476 osgwind->addCommandDelete(objectInOperation);
00477 }
00478 }
00479
00480 void RightView::OnObjectrightmenuRotate()
00481 {
00482 if(objectInOperation!=NULL){
00483 osgwind->addCommandRotate(10,objectInOperation);
00484 }
00485 }
00486
00487 void RightView::OnFreeplacerightmenuPaste()
00488 {
00489
00490 osgwind->addCommandPaste(operationPosition);
00491 }
00492
00493
00494
00495 void RightView::OnVehicleKamyon()
00496 {
00497 osgwind->addCommandInsertVehicle(operationPosition,"models/carModels/dodgemax/butun.osg",0.025);
00498 }
00499
00500
00501 void RightView::OnTrafficsignAda()
00502 {
00503
00504 osgwind->addCommandInsertTrafficSign(operationPosition,DIKKAT);
00505 }
00506
00507 void RightView::OnTrafficlightRed()
00508 {
00509
00510 osgwind->addCommandInsertTrafficLight(operationPosition,NORMAL_ISIK,KIRMIZI,KIRMIZI);
00511 }
00512
00513 void RightView::OnTrafficlightYellow()
00514 {
00515
00516 osgwind->addCommandInsertTrafficLight(operationPosition,NORMAL_ISIK,SARI,SARI);
00517 }
00518
00519 void RightView::OnTrafficlightGreen()
00520 {
00521 osgwind->addCommandInsertTrafficLight(operationPosition,NORMAL_ISIK,YESIL,YESIL);
00522 }
00523
00524 void RightView::OnEnvironmentalobjectHouse()
00525 {
00526 if(objectInOperation==NULL){
00527 AfxMessageBox("You selected house light menu item");
00528 }
00529 }
00530
00531
00532 void RightView::OnFreeplacerightmenuInserttext()
00533 {
00534 CTextDlg textdlg;
00535 textdlg.DoModal();
00536 CString aa;
00537 aa = textdlg.getTextString();
00538 string a = aa.GetString();
00539 CommandText* cmdText = new CommandText(osgwind);
00540 textperFrame *tpFrame = new textperFrame;
00541 tpFrame->textgeode=new osg::Geode;
00542 tpFrame->textGroup=new osg::Group;
00543
00544 tpFrame->textgeode = cmdText->createText(a);
00545 tpFrame->frameNum = osgwind->getCurrentFrameId();
00546 tpFrame->textGroup->addChild((cmdText->CreateHUD(cmdText->createText(a), 1440, 900)).get());
00547 osgwind->getTextArray().push_back(tpFrame);
00548
00549
00550 osgwind->getTextRoot()->addChild (tpFrame->textGroup.get());
00551 }
00552
00553 void RightView::OnCameraYawleft()
00554 {
00555 CommandCamera *cmdCamera = new CommandCamera(this,osgwind);
00556 cmdCamera->MoveLeft();
00557 }
00558
00559
00560 void RightView::OnCameraYawright()
00561 {
00562 CommandCamera *cmdCamera = new CommandCamera(this,osgwind);
00563 cmdCamera->MoveRight();
00564 }
00565
00566
00567 void RightView::OnCameraPitchup()
00568 {
00569 CommandCamera *cmdCamera = new CommandCamera(this,osgwind);
00570 cmdCamera->MoveUp();
00571 }
00572
00573 void RightView::OnCameraPitchdown()
00574 {
00575 CommandCamera *cmdCamera = new CommandCamera(this,osgwind);
00576 cmdCamera->MoveDown();
00577 }
00578
00579 void RightView::OnCameraZoomin()
00580 {
00581 CommandCamera *cmdCamera = new CommandCamera(this,osgwind);
00582 cmdCamera->ZoomIn();
00583 }
00584
00585 void RightView::OnCameraZoomout()
00586 {
00587 CommandCamera *cmdCamera = new CommandCamera(this,osgwind);
00588 cmdCamera->ZoomOut();
00589 }
00590
00591 void RightView::OnDikkat()
00592 {
00593 osgwind->addCommandInsertTrafficSign(operationPosition,DIKKAT);
00594 }
00595
00596 void RightView::OnUpdateDikkat(CCmdUI *pCmdUI)
00597 {
00598 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00599 }
00600
00601 void RightView::OnTrafficsignYolver32931()
00602 {
00603 osgwind->addCommandInsertTrafficSign(operationPosition,YOL_VER);
00604 }
00605
00606 void RightView::OnUpdateTrafficsignYolver32931(CCmdUI *pCmdUI)
00607 {
00608 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00609 }
00610
00611 void RightView::OnTrafficsignIsikliisaretcihazi32932()
00612 {
00613
00614 osgwind->addCommandInsertTrafficSign(operationPosition,ISIKLI_ISARET_CIHAZI);
00615 }
00616
00617 void RightView::OnUpdateTrafficsignIsikliisaretcihazi32932(CCmdUI *pCmdUI)
00618 {
00619 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00620 }
00621
00622 void RightView::OnTrafficsignSagatehlikeliviraj32933()
00623 {
00624 osgwind->addCommandInsertTrafficSign(operationPosition,SAGA_TEHLIKELI_VIRAJ);
00625 }
00626
00627 void RightView::OnUpdateTrafficsignSagatehlikeliviraj32933(CCmdUI *pCmdUI)
00628 {
00629 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00630 }
00631
00632 void RightView::OnTrafficsignSolatehlikeliviraj32934()
00633 {
00634
00635
00636 }
00637
00638 void RightView::OnUpdateTrafficsignSolatehlikeliviraj32934(CCmdUI *pCmdUI)
00639 {
00640 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00641 }
00642
00643 void RightView::OnTrafficsignSagasureklitehlikeliviraj32935()
00644 {
00645
00646 osgwind->addCommandInsertTrafficSign(operationPosition,SAGA_TEHLIKELI_DEVAMLI_VIRAJ);
00647 }
00648
00649 void RightView::OnUpdateTrafficsignSagasureklitehlikeliviraj32935(CCmdUI *pCmdUI)
00650 {
00651 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00652 }
00653
00654
00655 void RightView::OnTrafficsignSolasureklitehlikeliviraj32936()
00656 {
00657
00658 osgwind->addCommandInsertTrafficSign(operationPosition,SOLA_TEHLIKELI_DEVAMLI_VIRAJ);
00659 }
00660
00661
00662 void RightView::OnUpdateTrafficsignSolasureklitehlikeliviraj32936(CCmdUI *pCmdUI)
00663 {
00664 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00665 }
00666
00667
00668 void RightView::OnTrafficsignSaganayol32937()
00669 {
00670
00671 osgwind->addCommandInsertTrafficSign(operationPosition,SAGDAN_ANAYOL_TALIYOL_KAVSAGI);
00672
00673 }
00674
00675 void RightView::OnUpdateTrafficsignSaganayol32937(CCmdUI *pCmdUI)
00676 {
00677 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00678 }
00679
00680 void RightView::OnTrafficsignSolanayol32942()
00681 {
00682 osgwind->addCommandInsertTrafficSign(operationPosition,SOLDAN_ANAYOL_TALIYOL_KAVSAGI);
00683 }
00684
00685 void RightView::OnUpdateTrafficsignSolanayol32942(CCmdUI *pCmdUI)
00686 {
00687 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00688 }
00689
00690 void RightView::OnTrafficsignSagadonulmez32944()
00691 {
00692 osgwind->addCommandInsertTrafficSign(operationPosition,SAGA_DONULMEZ);
00693 }
00694
00695 void RightView::OnUpdateTrafficsignSagadonulmez32944(CCmdUI *pCmdUI)
00696 {
00697 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00698 }
00699
00700 void RightView::OnTrafficsignSoladonulmez32945()
00701 {
00702 osgwind->addCommandInsertTrafficSign(operationPosition,SOLA_DONULMEZ);
00703 }
00704
00705 void RightView::OnUpdateTrafficsignSoladonulmez32945(CCmdUI *pCmdUI)
00706 {
00707 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00708 }
00709
00710 void RightView::OnTrafficsignUdonusuyapilmaz32946()
00711 {
00712
00713 osgwind->addCommandInsertTrafficSign(operationPosition,U_DONUSU_YAPILMAZ);
00714 }
00715
00716 void RightView::OnUpdateTrafficsignUdonusuyapilmaz32946(CCmdUI *pCmdUI)
00717 {
00718 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00719 }
00720
00721 void RightView::OnTrafficsignOndekitasitigecmekyasaktir32947()
00722 {
00723
00724 osgwind->addCommandInsertTrafficSign(operationPosition,ONDEKI_TASITI_GECMEK_YASAKTIR);
00725 }
00726
00727 void RightView::OnUpdateTrafficsignOndekitasitigecmekyasaktir32947(CCmdUI *pCmdUI)
00728 {
00729 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00730 }
00731
00732 void RightView::OnTrafficsignSagamecburiyon32948()
00733 {
00734
00735 osgwind->addCommandInsertTrafficSign(operationPosition,SAGA_MECBURI_YON);
00736 }
00737
00738 void RightView::OnUpdateTrafficsignSagamecburiyon32948(CCmdUI *pCmdUI)
00739 {
00740 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00741 }
00742
00743 void RightView::OnTrafficsignSolamecburiyon32949()
00744 {
00745
00746 osgwind->addCommandInsertTrafficSign(operationPosition,SOLA_MECBURI_YON);
00747 }
00748
00749 void RightView::OnUpdateTrafficsignSolamecburiyon32949(CCmdUI *pCmdUI)
00750 {
00751 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00752 }
00753
00754 void RightView::OnTrafficsignIlerimecburiyon32950()
00755 {
00756
00757 osgwind->addCommandInsertTrafficSign(operationPosition,ILERI_MECBURI_YON);
00758 }
00759
00760
00761 void RightView::OnUpdateTrafficsignIlerimecburiyon32950(CCmdUI *pCmdUI)
00762 {
00763 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00764 }
00765
00766 void RightView::OnTrafficsignIlerivasagamecburiyon32951()
00767 {
00768
00769 osgwind->addCommandInsertTrafficSign(operationPosition,ILERI_SAGA_MECBURI_YON);
00770 }
00771
00772 void RightView::OnUpdateTrafficsignIlerivasagamecburiyon32951(CCmdUI *pCmdUI)
00773 {
00774 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00775 }
00776
00777 void RightView::OnTrafficsignIlerivesolamecburiyon32952()
00778 {
00779
00780 osgwind->addCommandInsertTrafficSign(operationPosition,ILERI_SOLA_MECBURI_YON);
00781 }
00782
00783 void RightView::OnUpdateTrafficsignIlerivesolamecburiyon32952(CCmdUI *pCmdUI)
00784 {
00785 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00786 }
00787
00788 void RightView::OnVehicleAutomobile()
00789 {
00790
00791 osgwind->addCommandInsertVehicle(operationPosition,"models/carModels/dodgemax/butun.osg",0.025);
00792 }
00793
00794 void RightView::OnUpdateVehicleAutomobile(CCmdUI *pCmdUI)
00795 {
00796 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00797 }
00798
00799 void RightView::OnVehicleTruck()
00800 {
00801
00802 osgwind->addCommandInsertVehicle(operationPosition,"models/carModels/semimax/butun.osg",0.025);
00803 }
00804
00805 void RightView::OnUpdateVehicleTruck(CCmdUI *pCmdUI)
00806 {
00807 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00808 }
00809
00810 void RightView::OnEnvironmentalobjectHouse32909()
00811 {
00812
00813 osgwind->addCommandInsertEnvObj(operationPosition,"models/environmentModels/house3/house3.osg",0.005);
00814 }
00815
00816 void RightView::OnUpdateEnvironmentalobjectHouse32909(CCmdUI *pCmdUI)
00817 {
00818 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00819 }
00820
00821 void RightView::OnUpdateEnvironmentalobjectHouse(CCmdUI *pCmdUI)
00822 {
00823 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00824 }
00825
00826 void RightView::OnUpdateCameraYawleft32849(CCmdUI *pCmdUI)
00827 {
00828 }
00829
00830 void RightView::OnFreeplacerightmenuInsertaudio()
00831 {
00832 if(osgwind->m_b_AudioInserted ) osgwind->m_b_AudioInserted = false;
00833 else osgwind->m_b_AudioInserted = true;
00834 }
00835
00836 void RightView::OnUpdateFreeplacerightmenuInsertaudio(CCmdUI *pCmdUI)
00837 {
00838 pCmdUI->SetCheck(osgwind->m_b_AudioInserted);
00839 }
00840
00841 void RightView::OnTrafficsignSolatehlikeliviraj32957()
00842 {
00843
00844 osgwind->addCommandInsertTrafficSign(operationPosition,SOLA_TEHLIKELI_VIRAJ);
00845 }
00846
00847 void RightView::OnUpdateTrafficsignSolatehlikeliviraj32957(CCmdUI *pCmdUI)
00848 {
00849 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00850 }
00851
00852 void RightView::OnTrafficsignSagasureklitehlikeliviraj32958()
00853 {
00854 osgwind->addCommandInsertTrafficSign(operationPosition,SAGA_TEHLIKELI_DEVAMLI_VIRAJ);
00855 }
00856
00857 void RightView::OnUpdateTrafficsignSagasureklitehlikeliviraj32958(CCmdUI *pCmdUI)
00858 {
00859 pCmdUI->Enable(osgwind->getCurrentFrameId() != -1);
00860 }
00861
00862 void RightView::OnTrafficsignSolasureklitehlikeliviraj32956()
00863 {
00864 osgwind->addCommandInsertTrafficSign(operationPosition,SOLA_TEHLIKELI_DEVAMLI_VIRAJ);
00865 }
00866
00867 void RightView::OnTrafficsignSaganayol32959()
00868 {
00869 osgwind->addCommandInsertTrafficSign(operationPosition,SAGDAN_ANAYOL_TALIYOL_KAVSAGI);
00870 }
00871
00872 void RightView::OnTrafficsignSolanayol32960()
00873 {
00874 osgwind->addCommandInsertTrafficSign(operationPosition,SOLDAN_ANAYOL_TALIYOL_KAVSAGI);
00875 }
00876
00877 void RightView::OnTrafficsignSagadonulmez32961()
00878 {
00879 osgwind->addCommandInsertTrafficSign(operationPosition,SAGA_DONULMEZ);
00880 }
00881
00882 void RightView::OnTrafficsignSoladonulmez32962()
00883 {
00884 osgwind->addCommandInsertTrafficSign(operationPosition,SOLA_DONULMEZ);
00885 }
00886
00887 void RightView::OnTrafficsignUdonusuyapilmaz32963()
00888 {
00889 osgwind->addCommandInsertTrafficSign(operationPosition,SOLA_DONULMEZ);
00890 }
00891
00892 void RightView::OnTrafficsignOndekitasitigecmekyasaktir32964()
00893 {
00894 osgwind->addCommandInsertTrafficSign(operationPosition,ONDEKI_TASITI_GECMEK_YASAKTIR);
00895 }
00896
00897 void RightView::OnTrafficsignSagamecburiyon32965()
00898 {
00899 osgwind->addCommandInsertTrafficSign(operationPosition,SAGA_MECBURI_YON);
00900 }
00901
00902 void RightView::OnTrafficsignSolamecburiyon32966()
00903 {
00904 osgwind->addCommandInsertTrafficSign(operationPosition,SOLA_MECBURI_YON);
00905 }
00906
00907 void RightView::OnTrafficsignIlerimecburiyon32967()
00908 {
00909 osgwind->addCommandInsertTrafficSign(operationPosition,ILERI_MECBURI_YON);
00910 }
00911
00912 void RightView::OnTrafficsignIlerivasagamecburiyon32968()
00913 {
00914 osgwind->addCommandInsertTrafficSign(operationPosition,ILERI_SAGA_MECBURI_YON);
00915 }
00916
00917 void RightView::OnTrafficsignIlerivesolamecburiyon32969()
00918 {
00919 osgwind->addCommandInsertTrafficSign(operationPosition,ILERI_SOLA_MECBURI_YON);
00920 }